package com.pearadmin.modules.sys.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.pearadmin.common.web.domain.request.PageDomain;
import com.pearadmin.modules.sys.domain.WorkBlock;
import com.pearadmin.modules.sys.mapper.WorkBlockMapper;
import com.pearadmin.modules.sys.service.IWorkBlockService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 碳块工作记录Service业务层处理
 *
 * @author Mr.Ling
 * @date 2021-11-26
 */
@Service
public class WorkBlockServiceImpl implements IWorkBlockService {
    @Autowired
    private WorkBlockMapper workBlockMapper;

    /**
     * 查询碳块工作记录
     *
     * @param id 碳块工作记录ID
     * @return 碳块工作记录
     */
    @Override
    public WorkBlock selectWorkBlockById(String id) {
        return workBlockMapper.selectWorkBlockById(id);
    }

    /**
     * 查询碳块工作记录列表
     *
     * @param workBlock 碳块工作记录
     * @return 碳块工作记录
     */
    @Override
    public List<WorkBlock> selectWorkBlockList(WorkBlock workBlock) {
        return workBlockMapper.selectWorkBlockList(workBlock);
    }

    /**
     * 查询碳块工作记录
     * @param workBlock 碳块工作记录
     * @param pageDomain
     * @return 碳块工作记录 分页集合
     * */
    @Override
    public PageInfo<WorkBlock> selectWorkBlockPage(WorkBlock workBlock, PageDomain pageDomain) {
        PageHelper.startPage(pageDomain.getPage(), pageDomain.getLimit());
        List<WorkBlock> data = workBlockMapper.selectWorkBlockList(workBlock);
        return new PageInfo<>(data);
    }

    /**
     * 新增碳块工作记录
     *
     * @param workBlock 碳块工作记录
     * @return 结果
     */
    @Override
    public int insertWorkBlock(WorkBlock workBlock) {
        return workBlockMapper.insertWorkBlock(workBlock);
    }

    /**
     * 修改碳块工作记录
     *
     * @param workBlock 碳块工作记录
     * @return 结果
     */
    @Override
    public int updateWorkBlock(WorkBlock workBlock) {
        return workBlockMapper.updateWorkBlock(workBlock);
    }

    /**
     * 删除碳块工作记录对象
     *
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteWorkBlockByIds(String[] ids) {
        return workBlockMapper.deleteWorkBlockByIds(ids);
    }

    /**
     * 删除碳块工作记录信息
     *
     * @param id 碳块工作记录ID
     * @return 结果
     */
    @Override
    public int deleteWorkBlockById(String id) {
        return workBlockMapper.deleteWorkBlockById(id);
    }
}
